package com.example.pertecttime.fragent.friend;


import android.content.Intent;
import android.view.View;
import android.widget.ExpandableListView;

import com.example.pertecttime.R;
import com.example.pertecttime.activity.login.loginActivity;
import com.example.pertecttime.adapter.MyListViewAdapter;
import com.example.pertecttime.base.BaseFragment;
import com.example.pertecttime.entity.FriendBean;
import com.example.pertecttime.entity.GroupBean;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by 半生瓜 on 2017/7/21.
 */

public class FriendFragment extends BaseFragment<FriendPresent, EriendModel>implements ExpandableListView.OnChildClickListener{
    private List<GroupBean> list;
    private ExpandableListView mListView;
    private MyListViewAdapter adapter;
    @Override
    public int getLayoutId() {
        return R.layout.friendslayout;
    }

    @Override
    public void initView() {
        initData();
        mListView=(ExpandableListView) getView().findViewById(R.id.expand);
        adapter = new MyListViewAdapter(list, context);
        mListView.setAdapter(adapter);
        mListView.setGroupIndicator(null);
//      mListView.expandGroup(0);
        mListView.setOnChildClickListener(this);

    }

    private void initData() {
        list = new ArrayList<GroupBean>();
        {
            List<FriendBean> list1 = new ArrayList<FriendBean>();
            FriendBean cb1 = new FriendBean(null,"妈妈", "123");
            FriendBean cb2 = new FriendBean(null,"爸爸", "456");
            FriendBean cb3 = new FriendBean(null,"爷爷", "789");
            FriendBean cb4 = new FriendBean(null,"妹妹", "000");
            list1.add(cb1);
            list1.add(cb2);
            list1.add(cb3);
            list1.add(cb4);
            GroupBean gb1 = new GroupBean("家", list1);
            list.add(gb1);
        }
        {
            List<FriendBean> list1 = new ArrayList<FriendBean>();
            FriendBean cb1 = new FriendBean(null,"张三", "123");
            FriendBean cb2 = new FriendBean(null,"李四", "456");
            FriendBean cb3 = new FriendBean(null,"王五", "789");
            FriendBean cb4 = new FriendBean(null,"赵六", "000");
            FriendBean cb5 = new FriendBean(null,"风起", "1111");
            FriendBean cb6 = new FriendBean(null,"马坝", "222");
            FriendBean cb7 = new FriendBean(null,"迁就", "3333333");
            list1.add(cb1);
            list1.add(cb2);
            list1.add(cb3);
            list1.add(cb4);
            list1.add(cb5);
            list1.add(cb6);
            list1.add(cb7);
            GroupBean gb1 = new GroupBean("我的朋友", list1);
            list.add(gb1);
        }
        {
            List<FriendBean> list1 = new ArrayList<FriendBean>();
            FriendBean cb1 = new FriendBean(null,"Tom", "123");
            FriendBean cb2 = new FriendBean(null,"Jerry", "456");
            FriendBean cb4 = new FriendBean(null,"Bush", "000");
            list1.add(cb1);
            list1.add(cb2);
            list1.add(cb4);
            GroupBean gb1 = new GroupBean("国际友人", list1);
            list.add(gb1);
        }
        {
            List<FriendBean> list1 = new ArrayList<FriendBean>();
            FriendBean cb1 = new FriendBean(null,"赵工", "123");
            FriendBean cb2 = new FriendBean(null,"马工", "456");
            FriendBean cb3 = new FriendBean(null,"王工", "789");
            FriendBean cb4 = new FriendBean(null,"李工", "000");
            FriendBean cb5 = new FriendBean(null,"为工", "000");
            list1.add(cb1);
            list1.add(cb2);
            list1.add(cb3);
            list1.add(cb4);
            list1.add(cb5);
            GroupBean gb1 = new GroupBean("同事", list1);
            list.add(gb1);
        }
    }


    @Override
    public void initclicklisten() {

    }

    @Override
    public boolean onChildClick(ExpandableListView parent, View v, int groupPosition, int childPosition, long id) {
        Intent intent=new Intent(getActivity(),loginActivity.class);
        startActivity(intent);
        return true;
    }
}
